import("//llvm/tools/cctools_symlinks.gni")
import("//llvm/utils/TableGen/tablegen.gni")
import("//llvm/utils/gn/build/driver_executable.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")

tablegen("LipoOpts") {
  visibility = [ ":llvm-lipo" ]
  args = [ "-gen-opt-parser-defs" ]
}

if (llvm_install_cctools_symlinks) {
  symlink_or_copy("lipo") {
    deps = [ ":llvm-lipo" ]
    source = "llvm-lipo"
    output = "$root_out_dir/bin/lipo"
  }
}

# //:llvm-lipo depends on this symlink target, see comment in //BUILD.gn.
group("symlinks") {
  deps = [ ":llvm-lipo" ]
  if (llvm_install_cctools_symlinks) {
    deps += [ ":lipo" ]
  }
}

driver_executable("llvm-lipo") {
  deps = [
    ":LipoOpts",
    "//llvm/lib/Object",
    "//llvm/lib/Option",
    "//llvm/lib/Support",
    "//llvm/lib/Target:TargetsToBuild",
    "//llvm/lib/TargetParser",
  ]
  sources = [ "llvm-lipo.cpp" ]
}
